﻿namespace Git.Storage.WebApi.Extensions.CorsExtend
{
    /// <summary>
    /// 跨域配置扩展  
    /// </summary>
    public static class AddCorsExtension
    {

        public static void AddCorsSetup(this IServiceCollection services, string? policyName)
        {
            services.AddCors(option =>
            {
                //策略1 
                option.AddPolicy(policyName, policy =>
                {
                    policy.AllowAnyOrigin()
                    .AllowAnyMethod()
                    .AllowAnyHeader();
                });
                ////策略2
                //option.AddPolicy("", policy =>
                //{
                //    policy.AllowAnyOrigin()
                //    .AllowAnyMethod()
                //    .AllowAnyHeader();
                //});
                ////策略3
                //option.AddPolicy("", policy =>
                //{
                //    policy.AllowAnyOrigin()
                //    .AllowAnyMethod()
                //    .AllowAnyHeader();
                //});

            });


        }

        public static void UserCors(this IApplicationBuilder app, string? policyName) => app.UseCors(policyName);




    }
}
